#ifndef CARLOGIN_H
#define CARLOGIN_H
#include "baseptc.h"

namespace protocal{
class CarLogin : public BasePtc
{
public:
    CarLogin()
    {
        this->source = CAR;
        this->car_command = CAR_LOGIN;
        this->size = sizeof(CarLogin);
    };
public:
    char usr_name[10];
    char password[10];
public:
    int recv(int sock)
    {

        char buff[size];
        unsigned int recvsize = 0;
        unsigned int ret = 0;
        while(recvsize < this->size - sizeof(BasePtc))
        {
            ret = read(sock,buff + sizeof(BasePtc) + recvsize,size);
            recvsize += ret;
        }
        CarLogin* tmp = (CarLogin*)buff;
        memcpy(this->usr_name,tmp->usr_name,sizeof(this->usr_name));
        memcpy(this->password,tmp->password,sizeof(this->password));

        return recvsize;

    };
    int send(int sock)
    {
        return write(sock,this,sizeof(CarLogin));
    };
};
}
#endif // CARLOGIN_H
